#!/bin/usr/python3

import itchat
import time
import itchat.content 

#登录微信
#itchat.auto_login(hotReload=True)#hotReload=True 可暂存登录状态，退出后一定时间内重启不用再次扫码登录

#发送消息给特定好友
itchat.auto_login(hotReload=True)
friends_list = itchat.get_friends(update=True)
users = itchat.search_friends(name=u'匡扶正义的四喜丸子')
userName = users[0]["UserName"]
itchat.send('正在测试微信机器人...',toUserName=userName)

#itchat.run()


@itchat.msg_register(itchat.content.TEXT)
def reply_msg(msg):
    print("收到一条信息:",msg.text)

if __name__ == '__main__':
    itchat.auto_login()
    time.sleep(5)
    itchat.send("小助手,你好!",toUserName='user_id')#user_id为微信号
    #保持运行
    itchat.run()



